import http from '@/utils/request';

interface MyRequestOptions {
	url : string;
	method : 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
	data ?: Record<string, unknown>;
	ticket ?: number;
}

export async function selectPadTask(data) : Promise<any> {
	const options : MyRequestOptions = {
		url: '/padTask/selectPadTask',
		method: 'POST',
		data: data,
		ticket: 1, // 为1带satoken
	};
	try {
		const response = await http.globalRequest(options);
		if (response.code === 2000) {
			return response.data;
		} else { throw response.msg }
	} catch (error) {
		throw error;
	}
}

/**
 * @description: 待办数据
 */
export async function queryTaskDetail(data) : Promise<any> {
	const options : MyRequestOptions = {
		url: '/padTask/queryTaskDetail',
		method: 'POST',
		data: data,
		ticket: 1, // 为1带satoken
	};
	try {
		const response = await http.globalRequest(options);
		if (response.code === 2000) {
			return response.data;
		} else { throw response.msg }
	} catch (error) {
		throw error;
	}
}
/**
 * @description: 合格提交
 */
export async function submitQualifiedTaskResult(data) : Promise<any> {
	const options : MyRequestOptions = {
		url: '/padTask/submitQualifiedTaskResult',
		method: 'POST',
		data: data,
		ticket: 1, // 为1带satoken
	};
	try {
		const response = await http.globalRequest(options);
		if (response.code === 2000) {
			return response.data;
		} else {
			throw response.msg
		}
	} catch (error) {
		throw error;

	}
}
/**
 * @description: 不合格问题列表
 */
export async function queryAllQualifiedReason() : Promise<any> {
	const options = {
		url: '/padTask/queryAllQualifiedReason',
		method: 'GET',
		ticket: 1, // 为1带satoken
	};
	try {
		const response = await http.globalRequest(options);
		if (response.code === 2000) {
			return response.data;
		} else { throw response.msg }
	} catch (error) {
		throw error;
	}
}
/**
 * @description: 删除单个图片
 */
export async function deleteUnQualifiedImage(data) : Promise<any> {
	const options = {
		url: '/padTask/deleteUnQualifiedImage',
		method: 'POST',
		ticket: 1, // 为1带satoken
		data: data
	};
	try {
		const response = await http.globalRequest(options);
		if (response.code === 2000) {
			return response.data;
		} else { throw response.msg }
	} catch (error) {
		throw error;
	}
}
/**
 * @description: 删除全部图片
 */
export async function deleteImage(data) : Promise<any> {
	const options = {
		url: '/padTask/deleteImage',
		method: 'POST',
		ticket: 1, // 为1带satoken
		data: data
	};
	try {
		const response = await http.globalRequest(options);
		if (response.code === 2000) {
			return response.data;
		} else { throw response.msg }
	} catch (error) {
		throw error;
	}
}
/**
 * @description: 不合格问题提交
 */
export async function submitUnQualifiedReason(data) : Promise<any> {
	const options = {
		url: '/padTask/submitUnQualifiedReason',
		method: 'POST',
		ticket: 1, // 为1带satoken
		data: data
	};
	try {
		const response = await http.globalRequest(options);
		if (response.code === 2000) {
			return response.data;
		} else { throw response.msg }
	} catch (error) {
		throw error;
	}
}
/**
 * @description: 已办检查结果
 */
export async function queryCheckResultByTaskId(data) : Promise<any> {
	const options = {
		url: '/padTask/queryCheckResultByTaskId',
		method: 'GET',
		ticket: 1, // 为1带satoken
		data: data
	};
	try {
		const response = await http.globalRequest(options);
		if (response.code === 2000) {
			return response.data;
		} else { throw response.msg }
	} catch (error) {
		throw error;
	}
}
/**
 * @description: 已办不良原因
 */
export async function queryUnQuaCheckByTaskId(data) : Promise<any> {
	const options = {
		url: '/padTask/queryUnQuaCheckByTaskId',
		method: 'GET',
		ticket: 1, // 为1带satoken
		data: data
	};
	try {
		const response = await http.globalRequest(options);
		if (response.code === 2000) {
			return response.data;
		} else { throw response.msg }
	} catch (error) {
		throw error;
	}
}
/**
 * @description: 不合格图片回显
 */
export async function selectUnQualifiedImage(data) : Promise<any> {
	const options = {
		url: '/padTask/selectUnQualifiedImage',
		method: 'GET',
		ticket: 1, // 为1带satoken
		data: data
	};
	try {
		const response = await http.globalRequest(options);
		if (response.code === 2000) {
			return response.data;
		} else { throw response.msg }
	} catch (error) {
		throw error;
	}
}
/**
 * @description: 字典
 */
export async function queryDictInfo(data) : Promise<any> {
	const options = {
		url: '/padTask/queryDictInfo',
		method: 'GET',
		ticket: 1, // 为1带satoken
		data: data
	};
	try {
		const response = await http.globalRequest(options);
		if (response.code === 2000) {
			return response.data;
		} else { throw response.msg }
	} catch (error) {
		throw error;
	}
}